/*
* GPL
* Free soft,no warranted
* We are all in the mud, but some of us are looking at the stars.
* We are not born for ourselves.
*/
/**
* @file io_service_pool.hpp
* @Synopsis
* @author Chai JunJun
* @date 2009-07-10
*/

#include <qserver/io_service_pool.hpp>

using namespace qserv ;

IOServicePoolPtr IOServicePoolSingleton::m_iosptr;
boost::recursive_mutex IOServicePoolSingleton::m_mutex;

IOServicePoolPtr IOServicePoolSingleton::getSingleton(std::size_t pool_size)
{
    if (m_iosptr.get() == NULL)
    {
        m_mutex.lock();
        if (m_iosptr.get() == NULL)
        {
            m_iosptr = IOServicePoolPtr(new io_service_pool(pool_size));
        }
        m_mutex.unlock();
    }
    return m_iosptr;
}